package com.bob.debt.callback;

import com.bob.debt.callback.factory.CallbackContext;
import com.chinabond.dcotc.sdk.interfaces.IOnServerMsgCallBack;
import com.chinabond.dcotc.sdk.pojo.DCOTCMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author admin
 */
@Slf4j
@Component
public class DCOTCServerMsgCallBack implements IOnServerMsgCallBack {

    @Resource
    protected CallbackContext callbackContext;

    @Override
    public void onMessage(DCOTCMessage dcotcMessage) {
        log.info("read dcotcMessage {}", dcotcMessage);
        doBusiness(dcotcMessage);
    }

    /**
     * 机构端接收处理逻辑
     */
    private void doBusiness(DCOTCMessage dcotcMessage) {
        // 1.申请机动额度反馈数据
        // 2.当前时点销售总量数据反馈数据
        // 3.销售及机动额度抓取资格管理
        // 4.手工分配机动额度
        // 5.技术应答
        // 6.文件下载通知
        // 7.技术公告通知
        // 8.文件上传通知反馈
        // 9.系统状态切换通知
        // 10.系统状态切换通知
        String msgType = dcotcMessage.getMsgType();
        CallbackHandler instance = callbackContext.getInstance(msgType, CallbackHandler.class);
        instance.process("");
        System.out.println("======处理逻辑结束啦======");
    }
}
